package day02;

public class RecursionDemo {
    public static void main(String[] args) {
        System.out.println(jie(6));

        System.out.println(divisor(12,20));

        System.out.println(times(12,20));

        System.out.println(yangHui(4,3));
    }
    public static int jie(int n){
        if(n==1){
            return 1;
        }
        return n*jie(n-1);
    }

    public static int fei(int n){
        if( n==1 || n==2){
            return 1;
        }
        return fei(n-1) + fei(n-2);
    }

    public static int divisor(int m,int n){
        if(m%n==0){
            return n;
        }
        return divisor(n,m%n);
    }

    public static int times(int m,int n){
        int result = divisor(m,n);
        return m*n/result;
    }
    public static int yangHui(int x,int y){
         if(y==1 || x==y){
             return 1;
         }
         return yangHui(x-1,y-1)+yangHui(x-1,y);
    }
}
